/*
 * @file drop_ball_server.cpp
 * @brief	action to drop the ball.
 *
 * @author	Michiel Hegemans
 * @author	Peter Evers
 *
 * @date	Jan 2013
 */
#include "servers/drop_ball_server.h"

/**
 * Constructor
 */
DropBallAction::DropBallAction(std::string name) : BaseServer(name),
	as_(nh_, name, boost::bind(&DropBallAction::execute, this, _1), false)
{
	as_.start();
}

/**
 * Destructor.
 */
DropBallAction::~DropBallAction() {
}

/**
 * Execute the goal, drop the ball.
 */
void DropBallAction::execute(const rp_states::DropBallGoalConstPtr &goal) {
	// send drop command
	comm::gripper msg;
	msg.state = GRIPPER_OPEN;
	publishGripper(msg);

	result_.ball_dropped = true;
	as_.setSucceeded(result_);
}

int main(int argc, char** argv) {
	ros::init(argc, argv, "drop_ball");

	DropBallAction dropball(ros::this_node::getName());
	ROS_INFO("Drop Ball Server Online.");
	ros::spin();

	return 0;
}
